<template>
  <div>
    <Modal v-model="userModalVisible">
      <template #header>
        <div>
          <span style="font-size: 16px;font-weight: bold">添加用户</span>
        </div>
      </template>
      <div style="padding: 8px 16px">
        <Form v-model="userInfoForm">
          <FormItem label="用户名">
            <Input v-model="userInfoForm.userCode"></Input>
          </FormItem>
          <FormItem label="昵称">
            <Input v-model="userInfoForm.userName"></Input>
          </FormItem>
          <FormItem label="性别">
            <RadioGroup v-model="userInfoForm.sex">
              <Radio :label="1">男</Radio>
              <Radio :label="0">女</Radio>
            </RadioGroup>
          </FormItem>
        </Form>
      </div>
      <template #footer>
        <Button type="default" @click="userModalVisible=false">取消</Button>
        <Button type="primary" @click="addUser">确定</Button>
      </template>
    </Modal>
  </div>

</template>
<script setup>
import {useUserStore} from "@/module-base/stores/userStore.js";
import {addUserByAdmin} from "@/module-base/api/sysManage.js";
import {storeToRefs} from "pinia";
const {userModalVisible,userInfoForm}=storeToRefs(useUserStore())
const emit = defineEmits(['addUserComplete'])

async function addUser() {
  try {
    const rs = await addUserByAdmin(userInfoForm.value)
    if (rs.success) {
      // handleGetList()
      emit('addUserComplete')
    }
  } catch (error) {
    console.log(error)
  }

}
</script>
<style scoped>

</style>